<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 是否显示设置敞口按钮 -->
<sys:funcAuth resCd="LinkCrAmt">
	<span id="isShowLinkCrAmtBtn" />
</sys:funcAuth>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<title>借阅超期提醒</title>
<jsp:include page="../../import.jsp" flush="true" />
<script type="text/javascript" src="<%=path %>/resource/lib/plugins/ajaxfileupload.js"></script>
</head>
<body class="iframeBody">
<div class="Wrapper">
	<div class="searchArea">
		<!-- 搜索表单开始 -->
		<form id="searchBar" enctype = "multipart/form-data">
			<div class="fieldset1 clearFix">
				<div class="FXBR">
					<div class="fieldBox">
						<div class="label">承租人名称</div>
						<div class="field">
							<input type="text" id="cstNm" name="cstNm" class="ui-textbox" ligerui="width: 160" value="">
						</div>
					</div>
					<div class="fieldBox">
						<div class="label">合同编号</div>
						<div class="field">
							<input type="text" id="contractNo" name="contractNo" class="ui-textbox" ligerui="width: 160" value="">
						</div>
					</div>
					<div class="fieldBox">
						<div class="label">支付表号</div>
						<div class="field">
							<input type="text" id="paySchNo" name="paySchNo" class="ui-textbox" ligerui="width: 160" value="">
						</div>
					</div>
					<div class="fieldBox">
						<div class="label">事业部</div>
						<div class="field">
<!-- 						onchange="toShengGongSi(this)" -->
							<select id="buOrgCd"  name="buOrgCd"  ligerui="width: 160" >
								<option value="">请选择</option>
								<c:forEach items="${buOrgCdList}" var="item">
									<option value="${item.key}">${item.value}</option>
								</c:forEach>
							</select>
							
						</div>
					</div>
					<div class="fieldBox col_33" id="cstMgrOrgCdId" >
		                <div class="label">省公司</div>
		                <div class="field">
		                    <input name="cstMgrOrgCd" id="cstMgrOrgCd" type="text" class="ui-textbox" value="">
		                </div>
		            </div>
					<div class="fieldBox">
	                    <div class="label">借出时间</div>
	                    <div class="field">
	                        <input ligerui="width: 82" name="actPayTmB" id="actPayTmB" type="text" class="ui-datepicker" value="">
	                        -
	                        <input ligerui="width: 82" name="actPayTmE" id="actPayTmE" type="text" class="ui-datepicker" value="">
	                    </div>
               	    </div>
               	    <div class="fieldBox">
	                    <div class="label">借出超期天数</div>
	                    <div class="field">
	                        <input ligerui="width: 82" name="beginDays" id="beginDays" type="text" value="" onblur="if(/\D/.test(this.value)){alert('只能输入数字');this.value='';}">
	                        -
	                        <input ligerui="width: 82" name="endDays" id="endDays" type="text" value="" onblur="if(/\D/.test(this.value)){alert('只能输入数字');this.value='';}">
	                    </div>
               	    </div>
               	    <div class="fieldBox col_33" id="cstMgrOrgCdId" >
		                <div class="label">借阅人</div>
		                <div class="field">
		                    <input name="crtUsrNa" id="crtUsrNa" type="text" class="ui-textbox" value="">
		                </div>
		            </div>
				</div>
				<div class="clearFix"></div>
				<!-- 表单按钮 -->
				<div class="btnsBox formBtns notRight">
					<span id="searchBtn" class="sq-button-round">查询</span>
					<span id="clearBtn" class="sq-button-round" onclick="clearBtnEvent();">清空</span>
					<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
					<span id="downBtn" class="sq-button-round" onclick="exportBtnEvent();">导出支付表号</span>
	            </div>
			</div>
		</form>
		<!-- 搜索表单结束 -->
	</div>
	<!-- 列表显示块 -->
	<div id="ligergrid1" class="sq-grid"></div>
</div>


<script type="text/javascript">
	var pageInApp={
		flag:false //tab页验证关闭
	};//to下一级子窗口 接口
	var pageInTab=null;//页签
	var loadedTabs=[];//页签
	var grid = null;
	$(function () {
		$("#paySchCds").css('display','none');
		initOrgTree();
	    initForm();//初始化表单
	    
	    initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
	    searchBtnEvent();//查询按钮事件
	    clearBtnEvent();//清空按钮
	});
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
		var data = form.getData();
		return data;
	}
	
	function initGrid(){
		$("#ligergrid1").ligerGrid({
			url:'<%=path%>/warrant/warrantfilemanage/initListBorrowOverdue.do',
			method:'get',
			parms:getSearchParams(),
			columns:[
				{ display: '承租人姓名',name: 'cstNm', minWidth: 30 , align:'center', enabledSort:true},
				{ display: '合同编号', name: 'contractNo', minWidth: 180 , align:'center', enabledSort:true},
				{ display: '支付表号', name: 'paySchNo', minWidth: 180 , align:'center', enabledSort:true},
				{ display: '借出时间', name: 'tocrtTm', width: 100, align:'center', enabledSort:true
				},
				{ display: '超期状态', name: 'returnState', width: 120 , enabledSort:true,
					render:function(rowdata, rowindex, value, column) {
						return (rowdata.overDay > 0)?"已超期":"未超期";//0未归还  1已归还
	            	}
				},
				{ display: '借出超期天数', name: 'overDay', width: 120 , enabledSort:true},
				{ display: '事业部', name: 'buOrgCdNm', width: 80, align:'center', enabledSort:true},
				{ display: '省公司', name: 'prOrgCdNm', width: 100, align:'center', enabledSort:true},
				{ display: '借阅人', name: 'crtUsrNa', width: 100, align:'center', enabledSort:true
				},
				{ display: '权证资料名称', name: 'fileName', width: 120 , enabledSort:true},
				{ display: '流程号', name: 'pNo', width: 100, align:'center', enabledSort:true},
				{ display:'操作',isSort:false,width:150,align:'center',
					render:function(rowdata, rowindex, value, column) {
						var h="";
						h+='<a class="sq-button-hasicon" href="javascript:viewTotal(';
		            	h+="'"+rowdata.contractNo+"',";
		            	h+="'"+rowdata.paySchNo+"'";
		                h+=")\"><i class='sqBtnIco_4'></i>查看     </a>";
		                if(rowdata.audStsCd == "1"){
			            	h+='<a class="sq-button-hasicon" href="javascript:longBorrowApply(';
			            	h+="'"+rowdata.id+"',";
			                h+=")\"><i class='sqBtnIco_4'></i>延期申请</a>";
						}
						return h;
					}
				}
			],
			pageSize:10,
			root:'rows',
			record:'total',
			hideLoadButton:false,
			width:'100%',
			height:'100%',
			heightDiff:-2,
			checkbox:false,//列表是否有选择框
			rownumbers:true,//列表是否有行号
			frozen: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            onBeforeShowData: function () {
                var grid = this;
                grid.collapsedRows = [];
            }
		});
		grid = liger.get("ligergrid1");
		grid.setHeight(100);
		//grid.options.isSingleCheck = true;//列表是否为单选
	}
	
	
	//清空按钮事件
	function clearBtnEvent(){
		$("#clearBtn").click(function(event) {
			$("#resetBtn").click();  //重置 input-text
			var form = liger.get("searchBar");
			form.setData({  //重置select等特殊表单
				"buOrgCd":"",//事业部
				"cstMgrOrgCd":""//省公司
			});
		});
	}
	//查询按钮事件
	function searchBtnEvent(){
		$("#searchBtn").click(function(event) {
			var form = ""; 
			form= new liger.get("searchBar");
			var data = form.getData();
// 			alert(JSON.stringify(data));
			for (name in data){
				grid.setParm(name,data[name]);
			};
			grid.reload();
		});
	}
	
	
	//导出信息
	function exportBtnEvent(){
		var form = new liger.get("searchBar");
		var data = form.getData();
// 		alert(JSON.stringify(data));
        data["eFlag"] = "tcsq";
		var wait_dialog = null;
		$.ajax({
			type: 'get',
			dataType:'json',
			url: '<%=path%>/warrant/warrantfilemanage/exportBtnEvent.do',
			data:data,
			beforeSend:function(){
				wait_dialog=$.ligerDialog.SQalert({content: '正在导出信息...',SQ_type: "waitting"});
			},
			success:function(msg){
				wait_dialog.close();
				if(msg.success == 1){
					window.open(msg.data);
				}else{
					$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				}
			} 
		});
	}
	
	//获取资产表中支付标号
	function ReadExcel(){ 
		$("#paySchCds").val("");//清空支付表号组
		$.ajaxFileUpload({  
		    url : "<%=path%>/warrant/warrantfilemanage/importExcel.do",  
		    dataType : 'json',  
		    data : {},
		    secureuri : false,  
		    fileElementId :'upfile',  
		    success : function(msg) { //服务器成功响应处理函数  
		    	 if(msg.success == 1){
		    		 if(msg.data == ""){
		    			 top.$.ligerDialog.SQalert({content: "上传的EXCEL支付表编号为空",SQ_type: "success"});
		    		 }else{
						 //赋值
			    		 $("#paySchCds").val(msg.data);
			    		 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
			    		 grid.reload();
		    		 }
    			 }else{
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
    			 }  
	        }  
	    });  
	}
	//查看详情
	function viewTotal(contractNo,paySchNo){
		//var timestamp=new Date().getTime();
		var param = '<%=path%>/archive/arcBorrowMain/viewTotal.do?contractNo=' + contractNo+'&paySchNoList=' + paySchNo ;
		Add_navTab('viewTotal'+paySchNo,'详情',param, function () {
			//grid.reload();
		});
	}
	//延期申请
	function longBorrowApply(id){
		var param = '<%=path%>/archive/arcBorrowMain/delayApply.do?from=delayApply&id='+id;
		Add_navTab('arcBorrowMainDelayApply'+id,'延期申请',param, function () {
// 			grid.reload();
		});
	}
	

	
	function initOrgTree(){
    	var params = {};
    	 searchOrgTree = $("#cstMgrOrgCd").ligerComboBox({
    		 width: 480,
             selectBoxWidth: 480,
             selectBoxHeight: 150,
             //限制只能选叶节点，父节点不能点击
             treeLeafOnly: false,
             valueField: 'orgCd',
             textField: 'orgDispNm',
             showTreePath: true,
             tree: {
                 ajaxType: 'get',
                 idFieldName:'orgCd',
                 textFieldName: 'orgDispNm',
                 checkbox: false,
                 parentIcon: "none",
                 childIcon: "none",
                 needCancel : false
             }
         });
    	 $.ajax({
     		type: 'get',
     		dataType:'json',
     		data: params,
     		url: '<%=path%>/warrant/warrantfilemanage/searchBuOrgTree.do',
     		success:function(msg){
     			if(msg.success == 1){
     				searchOrgTree.treeManager.setData(msg.data);
     				searchOrgTree.clear();
     				searchOrgTree.setValue('${currOrg}');
     			}else{
     				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
     			}
     		}
     	});

    }    
	    

</script>
</body>
</html>